package org.jeecg.common.constant.enums;

/**
 * Boolean 类型使用int表达
 * @author: qiang.zhou
 * @date: 2024/4/7 13:57
 **/
public enum BoolInt implements BaseEnum<Integer, String> {

    TRUE(1, "1", "是"),
    FALSE(0, "0", "否");

    private Integer code;
    private String value;
    private String name;

    BoolInt(Integer code, String value, String name) {
        this.code = code;
        this.name = name;
        this.value = value;
    }

    @Override
    public Integer getCode() {
        return this.code;
    }

    public String getValue() {
        return this.value;
    }

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public boolean checkCode(Integer code) {
        return this.code.equals(code);
    }

    public static BoolInt parseCode(Integer code) {
        for (BoolInt t: values()) {
            if (t.getCode().equals(code)) {
                return t;
            }
        }
        return null;
    }

    public static BoolInt parseValue(String code) {
        for (BoolInt t: values()) {
            if (t.getValue().equals(code)) {
                return t;
            }
        }
        return null;
    }

}
